package com.hc.springsecurity;

import com.hc.utils.MD5Util;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

public class MyPasswordEncoder implements PasswordEncoder {
    //加密：对网页传递过来的明文进行加密
    @Override
    public String encode(CharSequence charSequence) {
        return MD5Util.encode((String)charSequence);
    }
    //检验网页传递过来的明文charSequence和从数据库中查询出来的密文s是否匹配
    @Override
    public boolean matches(CharSequence charSequence, String s) {
        return s.equals(MD5Util.encode((String)charSequence));
    }

}
